package com.rpc.server.provide;

import com.rpc.config.PrayRpcProperties;
import com.rpc.protocal.serilization.RpcSerializationFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;

import java.util.HashMap;
import java.util.Map;

/**
 * ServerProviderProcessor
 * RPC服务提供后置处理器
 * @author 春江花朝秋月夜
 * @since 2024/1/18 11:23
 */
public class ServerProviderProcessor implements InitializingBean, BeanPostProcessor, EnvironmentAware {
    private Logger logger= LoggerFactory.getLogger(ServerProviderProcessor.class);
    PrayRpcProperties rpcProperties;//获取配置项里面的内容
    private static String serverAddress="127.0.0.1";
    private final Map<String, Object> rpcServiceMap = new HashMap<>();

    @Override
    public void afterPropertiesSet() throws Exception {
        RpcSerializationFactory.init();//初始化序列化工厂
    }

    @Override
    public void setEnvironment(Environment environment) {

    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        return BeanPostProcessor.super.postProcessAfterInitialization(bean, beanName);
    }
}
